package com.copro.chemdb.search;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.ihelpuoo.lang.NumericUtils;

import com.copro.chemdb.subject.Subject;
import com.copro.chemdb.subject.SubjectUtils;
import com.copro.simple.Application;

public class CanQuerySubjectsAction extends Action {

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		Application app = Application.me(request);
		int quesId = NumericUtils.parseInt(request.getParameter("quesId"), -1);
		List<Subject> subjects = SubjectUtils.listCanQuerySubjects(app, quesId);

		request.setAttribute("items", subjects);
		return mapping.findForward("list");
	}

}
